﻿using Glue.Converters;
using Xunit;

namespace GlueTests.BaseConverterTests
{
    public class When_mapping_between_nullable_and_its_regular_type
    {
        private readonly QuickConverter<int?, int> nullableToNormalConverter;

        public When_mapping_between_nullable_and_its_regular_type()
        {
            nullableToNormalConverter = new QuickConverter<int?, int>(x => x.GetValueOrDefault(), y => y);
        }

        [Fact]
        public void Should_resolve_when_no_nulls_are_present()
        {
            var shouldBeTen = nullableToNormalConverter.Map(10, 15);
            Assert.Equal(10,shouldBeTen);
        }

        [Fact]
        public void Should_resolve_when_from_is_null()
        {
            var shouldBeZero = nullableToNormalConverter.Map(null, 15);
            Assert.Equal(0, shouldBeZero);
        }

    }
}
